﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css"  media="all">
    <script src="js/0_common/jquery.min.js"></script>
    <script src="js/constants.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<style>
    .fgsq .layui-form-select .layui-input {
        padding-right: 0 !important;
    }
</style>
<body class="fgsq">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>企业复工复产服务</legend>
</fieldset>
<fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;">
    <legend>基本信息填写</legend>
<form class="layui-form" lay-filter="form-test" action=""   id="example" method="post">


    <div class="layui-form-item">
        <div class="" style="width: 774px;">
            <label class="layui-form-label">企业名称</label>
            <div class="layui-input-block">
                <input type="text" id="zd2" name="zd2" lay-verify="title" autocomplete="off" placeholder="请输入企业名称" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">统一社会信用代码</label>
            <div class="layui-input-block">
                <input type="text" id="zd1" name="zd1"  lay-verify="title" autocomplete="off" placeholder="请输入企业统一社会信用代码" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">企业地址</label>
            <div class="layui-input-block">
                <input type="text" id="zd4" name="zd4" lay-verify="title" autocomplete="off" placeholder="请输入单位地址" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline" style="display: none">
            <label class="layui-form-label">所属区县</label>
            <div class="layui-input-block">
                <input type="text" id="zd3" name="zd3"  autocomplete="off" placeholder="请输入所属区县" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">所属街道</label>
            <div class="layui-input-block">
                <input type="text" id="zd22" name="zd22" lay-verify="title" autocomplete="off" placeholder="请输入所属街道" class="layui-input">
            </div>
        </div>
        <div class="layui-inline" style="display: none">
            <label class="layui-form-label">所属楼宇、产业园</label>
            <div class="layui-input-block">
                <input  type="text" id="zd56" name="zd56" autocomplete="off" placeholder="所属楼宇、产业园(非楼宇、产业园内企业不用选择)" class="layui-input"/>
                (非楼宇、产业园内企业不用选择)
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">是否个体工商户</label>
            <div class="layui-input-block">
                <div style="width: 182px;">
                    <input type="radio" name="zd54" value="是" title="是">
                    <input type="radio" name="zd54" value="否" title="否" checked>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">企业法人</label>
            <div class="layui-input-block">
                <input type="text" id="zd5" name="zd5" lay-verify="title" autocomplete="off" placeholder="请输入法人代表" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">法人联系方式</label>
            <div class="layui-input-block">
                <input type="text" id="zd6" name="zd6" lay-verify="phone" autocomplete="off" placeholder="请输入手机号" class="layui-input">
            </div>
        </div>
    </div>

    <!--    新增字段-->

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">企业所有制</label>
            <div class="layui-input-block">
                <select name="zd50" lay-verify="required">
                    <option value=""></option>
                    <option value="0">国有企业</option>
                    <option value="1">民营企业</option>
                    <option value="2">外资及港澳台企业</option>
                </select>
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">所属行业</label>
            <div class="layui-input-block">
                <select name="zd51" lay-verify="required">
                    <option value=""></option>
                    <option value="0">农、林、牧、渔业</option>
                    <option value="1">采矿业</option>
                    <option value="2">制造业</option>
                    <option value="3">电力、热力、燃气及水生产和供应业</option>
                    <option value="4">建筑业</option>
                    <option value="5">批发和零售业</option>
                    <option value="6">交通运输、仓储和邮政业</option>
                    <option value="7">住宿和餐饮业</option>
                    <option value="8">信息传输、软件和信息技术服务业</option>
                    <option value="9">金融业</option>
                    <option value="10">房地产业</option>
                    <option value="11">租赁和商务服务业</option>
                    <option value="12">科学研究和技术服务业</option>
                    <option value="13">水利、环境和公共设施管理业</option>
                    <option value="14">居民服务、修理和其他服务业</option>
                    <option value="15">教育</option>
                    <option value="16">卫生和社会工作</option>
                    <option value="17">文化、体育和娱乐业</option>
                    <option value="18">公共管理、社会保障和社会组织</option>
                    <option value="19">国际组织</option>
                </select>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">24小时值班人员</label>
            <div class="layui-input-block">
                <input type="text" id="zd52" name="zd52" lay-verify="title" autocomplete="off" placeholder="请输入24小时值班人员" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">值班人员联系方式</label>
            <div class="layui-input-block">
                <input type="text" id="zd53" name="zd53" lay-verify="phone" autocomplete="off" placeholder="请输入值班人员联系方式" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        
        <div class="layui-inline">
            <label class="layui-form-label">复工原因</label>
            <div class="layui-input-block">
                <select name="zd57" lay-verify="required">
                    <option value=""></option>
                    <option value="0">公共事业运行必需</option>
                    <option value="1">疫情防控必需</option>
                    <option value="2">群众生活必需</option>
                    <option value="3">重要国计民生</option>
                    <option value="4">春节期间未停产</option>
                    <option value="5">特殊原因申请提前复工</option>
                    <option value="6">2月9日后正常复工</option>
                </select>
            </div>
        </div>
       <div class="layui-inline">
            <label class="layui-form-label">员工总数</label>
            <div class="layui-input-block">
                <input type="text" id="zd58" name="zd58" lay-verify="title" autocomplete="off" placeholder="请输入员工总数" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">外地返苏人数</label>
            <div class="layui-input-block">
                <input type="text" name="zd64" lay-verify="numberVerify" autocomplete="off" placeholder="请输入申请复工人数" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">疫情防控重点地区员工数</label>
            <div class="layui-input-block">
                <input type="text" name="zd59" lay-verify="numberVerify" autocomplete="off" placeholder="请输入疫情防控重点地区员工数" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <span id="ggyqyg" style="display: inline-block">!</span>
        </div>
    </div>

    <div class="layui-form-item">
        <div id="ggyqwz" style="width: 604px;margin-left: 200px;display: none">
            <div class="layui-inline">
                <span  style="color: #6f6f6f">备注重点区域的清单（湖北全省各市、浙江省温州市、台州市、杭州市、宁波市、河南省信阳市、驻马店市、安徽省合肥市、阜阳市、江西省南昌市）</span>
            </div>
        </div>
        <!--<div style="width: 774px;">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="zd60" placeholder="" class="layui-textarea"></textarea>
            </div>
        </div>-->
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">申请复工人数</label>
            <div class="layui-input-block">
                <input type="text" name="zd61" id='zd61'  lay-verify="numberVerify" autocomplete="off" placeholder="请输入申请复工人数" class="layui-input" oninput="value=value.replace(/[^\d]/g,'')">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">疫情防控重点地区复工人数</label>
            <div class="layui-input-block">
                <input type="text" name="zd62" lay-verify="numberVerify" autocomplete="off" placeholder="请输入疫情防控重点地区复工人数" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <span id="ggyqfk" style="display: inline-block">!</span>
        </div>
    </div>

    <div class="layui-form-item">
        <div id="ggyqfkwz" style="width: 604px;margin-left: 200px;display: none">
            <div class="layui-inline">
                <span  style="color: #6f6f6f">备注重点区域的清单（湖北全省各市、浙江省温州市、台州市、杭州市、宁波市、河南省信阳市、驻马店市、安徽省合肥市、阜阳市、江西省南昌市）</span>
            </div>
        </div>
        <!--<div style="width: 774px;">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="zd63" placeholder="" class="layui-textarea"></textarea>
            </div>
        </div>-->
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">疫情防控情况</label>
        <div style="width: 774px;">
            <input type="checkbox" name="zd65" title="疫情防控体系建设已到位">
            <input type="checkbox" name="zd66" title="职工统计分类管理已到位">
            <input type="checkbox" name="zd67" title="应急防控物资保障已到位">
            <input type="checkbox" name="zd68" title="疫情防控场所准备已到位">
        </div>
    </div>
    <!--    新增结束-->

    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">复工日期</label>
            <div class="layui-input-block">
                <input type="text" name="zd11" id="date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">填报日期</label>
            <div class="layui-input-block">
                <input type="text" name="zd12" id="date1" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" lay-submit="" class="layui-btn layui-btn-normal" id="baocun" lay-filter="demo1"> 保  存 </button>
            <button class="layui-btn" lay-submit="" lay-filter="next"  id="next" style="display: none" onclick="window.location.href = './Sec_ryManage.html'">下一步</button>
            <button type="reset" class="layui-btn layui-btn-primary"> 重  置 </button>
        </div>
    </div>
</form>

</fieldset>
<ul class="layui-timeline" style="display: block" id="time">

</ul>
<script src="layui/layui.js" charset="utf-8"></script>
<script src="js/constants.js"></script>
<script src="js/0_common/jquery.min.js"></script>
<script src="layui/jquery.serializejson.min.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    var ctx = Constants.path;
    var qyid = localStorage.getItem('qyid');

    $("#ggyqyg").mouseover(function () {
        document.getElementById('ggyqwz').style.display=''
    }).mouseout(function () {
        document.getElementById('ggyqwz').style.display='none'
    });

    $("#ggyqfk").mouseover(function () {
        document.getElementById('ggyqfkwz').style.display=''
    }).mouseout(function () {
        document.getElementById('ggyqfkwz').style.display='none'
    });
    checkStatus();

    function reformEnterpriseInfo() {
        $.ajax({
            type: "get",
            url: ctx + "/pb/qyxxs/"+qyid,
            success: function(r) {
                if (r.code == "200"){
                    var data = r.data;
                    $("#zd2").val(data.name)
                    $("#zd3").val(data.qu)
                    $("#zd22").val(data.street)
                    $("#zd4").val(data.address)
                    $("#zd5").val(data.faren)
                    $("#zd6").val(data.frphone)
                    $("#zd7").val(data.gsrenshu)
                    $("#zd56").val(data.louyu)
                    $('#zd58').val(data.gsrenshu)
                }
            }
        });
    }
    layui.use(['form', 'layedit', 'laydate','upload'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate,
            upload = layui.upload
        $.ajax({
            type: "get",
            url: ctx + "pb/qysqbs/findall",
            data:{
                "qyid":qyid
            },
            success: function(res) {
                if (res.data.length > 0) {
                    var lastIndex = res.data.length - 1;
                    var currentTable = res.data[lastIndex];
                    form.val('form-test', currentTable);
                } else {
                    reformEnterpriseInfo();
                }
            }});


        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1',
            value: new Date()
        });
        laydate.render({
            elem: '#date2',
            value: new Date()
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            title: function(value){
                if(value.length < 1){
                    return '请填写内容！';
                }
            },
            numberVerify: function(value){
                if (value.length <1){
                    return '请填写内容！';
                }else{
                    if (!/^\d+$/.test(value)){
                        return '请填写整数！'
                    }
                }
            }
            ,pass: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
            ,content: function(value){
                if(value.length < 18){
                    return '信用代码填写不正确！';
                }
            }
        });

        form.on("submit(next)", function () {
            window.location.href = "./Sec_ryManage.html";
            return false;
        });
        //监听提交
        form.on("submit(demo1)", function () {
            $('#baocun').attr({'disabled':'disabled'});
            var a=Number($("#zd58").val());
            var b=Number($("#zd61").val());
            if(b<=a){
                var obj1 = $("#example").serializeJSON()
                var obj = {};
                obj.zd1 = obj1.zd1
                obj.zd2 = obj1.zd2
                obj.zd3 = '姑苏区'
                obj.zd4 = obj1.zd4
                obj.zd5 = obj1.zd5
                obj.zd6 = obj1.zd6
                obj.zd11 = obj1.zd11
                obj.zd12 = obj1.zd12
                obj.zd22 = obj1.zd22
                obj.zd56 = ''
                for (let i = 50; i <= 70; i++) {
                    obj['zd' + i] = obj1['zd' + i];
                }
                obj.qyid = qyid;
                $.ajax({
                    type: "post",
                    url: ctx + "pv/cjqysqbs",
                    data: JSON.stringify(obj),
                    dataType:"json",
                    contentType:"application/json",
                    success: function(r) {
                        if (r.code == "200"){
                            layer.msg('保存成功！', {
                                icon: 1,
                                time: 1000 //2秒关闭（如果不配置，默认是3秒）
                            }, function(){
                                $('#next').show();
                                $('#baocun').removeAttr('disabled');
                            });
                        }else {
                            layer.msg('保存失败');
                            $('#baocun').removeAttr('disabled');
                        }
                    }
                });
                return false;
            }else{
                layer.msg('申请复工人数不得大于员工总数');
                $('#baocun').removeAttr('disabled');
            }

        });

    });

    //上报
    function sb(qyid) {
        $.ajax({
            type: "put",
            url: ctx + "pv/qyxxs/"+qyid,
            data: JSON.stringify({
                "status":"2"
            }),
            dataType:"json",
            contentType:"application/json",
            success: function(r) {
                if (r.code == "200"){
                    layer.msg('上报成功！', {
                        icon: 1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function(){
                        window.location.href = "test.html"
                    });
                }else {
                    layer.msg('提交失败');
                }
            }
        });
    }

    //查看详情
    function ck(id) {
        layer.open({
            type: 2,
            title:"申报详情",
            content: 'testXq.html?id='+id,
            offset: ['50px', '150px'],
            area: ['70%', '90%']
        });
    }

    //修改
    function xg(id) {
        layer.open({
            type: 2,
            title:"申报-修改",
            content: 'testXg.html?id='+id,
            offset: ['50px', '150px'],
            area: ['70%', '90%']
        });
    }

    // $('#next').click(function () {
    //     console.log('123')
    //
    // })

    function checkStatus(cb) {
        $.ajax({
            type: "get",
            url: ctx + "/pb/qyxxs/"+qyid,
            success: function(r) {
                if (r.code == "200"){
                    if (r.data.status >= 2) {
                        window.location.href = 'test.html'
                    } else {
                        if (cb) {
                            cb();
                        }
                    }
                }
            }
        });
    }

    $.ready(function () {
    })

</script>

</body>
</html>
